using System;
using System.Collections.Generic;
using UnityEngine;



[Serializable]
public class UavPath
{
    public List<PathData> points;


    public UavPath(List<Vector3> pathPoints)
    {
        points = new List<PathData>();
        for (var i = 0; i < pathPoints.Count; i++)
        {
            points.Add(new PathData
            {
                x = pathPoints[i].x,
                y = pathPoints[i].y,
                z = pathPoints[i].z,
                time = 0
            });
        }
    }

    public UavPath(List<Vector3> pathPoints, List<float> timeSpan)
    {
        if (pathPoints.Count != timeSpan.Count)
        {
            Debug.LogError("Path points count mismatch");
        }

        points = new List<PathData>();
        for (int i = 0; i < pathPoints.Count; i++)
        {
            points.Add(new PathData
            {
                x = pathPoints[i].x,
                y = pathPoints[i].y,
                z = pathPoints[i].z,
                time = timeSpan[i]
            });
        }
    }

    public void Add(Vector3 position, float time)
    {
        points.Add(new PathData
        {
            x = position.x,
            y = position.y,
            z = position.z,
            time = time
        });
    }

    public void Clear()
    {
        points.Clear();
    }

    [Serializable]
    public struct PathData
    {
        public float x;
        public float y;
        public float z;
        public float time;
    }
}